<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/19 0019
 * Time: 上午 10:30
 */
class Index  extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('index_model');
        $this->load->model('category_model');
        $this->load->model('array_model');
        $this->load->model('article_model');

        $this->load->model('ziying_model');

        $this->load->model('comment_model');


    }

    public function index()
    {
        if(!empty($_GET['cityId']))
        {
            $city = $_GET['cityId'];
        }else{
            $city=1;
        }
        $newlinelist = $this->article_model->get_track_and_act(array('sortkey' =>'created','limit' =>10,'cityId'=>$city));
        $poplinelist = $this->article_model->get_track_and_act(array('sortkey' =>'zan','limit' =>10,'cityId'=>$city));

        $ziying = $this->ziying_model->getList(array('city'=>$city));

        $this->success(array('newlinelist'=>$newlinelist,'poplinelist'=>$poplinelist,'ziying'=>$ziying));
    }

    public function city()
    {
        //城市 国家 自定义 地区
        $arrays = $this->array_model->getArrays();
        if(!empty($arrays))
        {

            $this->success($arrays);
        }else{

            $this->error('未找到数据');
        }
    }


   

    public function detail()
    {
        $id = $_GET['id'];
        $data = $this->article_model->detail($id);

        $con_data['type'] = 'TRACK';
        $con_data['id'] = $id;
        $con_data['limit'] = 5;
        $con_data['offset'] = 0;
        $coms = $this->comment_model->getActivityOrTrackComments($con_data);

        $this->success(array('data'=>$data,'coms' =>$coms));

    }


    public function ziying()
    {

    }

}